package cn.nfwx.tv.db;

import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Delete;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.OnConflictStrategy;
import android.arch.persistence.room.Query;
import android.arch.persistence.room.Update;

import java.util.List;

@Dao
public interface TsDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insert(TsProgramModel... tsProgramModels);

    @Update
    void update(TsProgramModel... tsProgramModels);

    @Delete
    void delete(TsProgramModel... tsProgramModels);

    @Query("SELECT * FROM tb_ts")
    List<TsProgramModel> queryForAll();

    //使用内连接查询
    @Query("SELECT tb_ts.*  from tb_program INNER JOIN tb_ts ON tb_program.id=tb_ts.program_id")
    List<TsProgramModel> getTsFromProgram();


    @Query("SELECT * FROM tb_ts WHERE program_id = :programId")
    List<TsProgramModel> getTsFromProgram(long programId);
}
